# -*- coding:utf-8 -*-

import utils.CDictQueue as CDictQueue
import pyamf.amf3 as amf3

class switchData(object):
    """ """
    def __init__(self):
        """ """
        self.saveQueue = CDictQueue.DictQueue();
        
    def saveData(self,buf):
        """ """
        bufArr = amf3.ByteArray(buf);
        bufArr.seek(0)
        exsitLen = len(bufArr);
        while not self.__leave and exsitLen:
            bufArr.endian = amf3.ByteArray.ENDIAN_LITTLE;
            nlen = bufArr.readShort();
            if exsitLen >= nlen:
                exsitLen -= nlen
                bufArr.endian = amf3.ByteArray.ENDIAN_BIG;
                msg  = bufArr.readShort();
                temp = bufArr.read(nlen-4);   
                if self.__listenQueue.has_key(msg):
                    pass
                else:
                    self.__saveQueue.put(msg,temp);
            else:
                break;
        
    def readData(self,key):
        """ """
        pass
        
        